//
//  MHHJvsJLCFMineInvestRecordCellJrPSbZ.m
//  qcb_ios
//
//  Created by Ji on 2018/8/30.
//  Copyright © 2018年 ski. All rights reserved.
//

#import "MHHJvsJLCFMineInvestRecordCellJrPSbZ.h"
#import "DarTMvJLCFMineInverstWebViewControllerJPeJHr.h"

@interface MHHJvsJLCFMineInvestRecordCellJrPSbZ ()

@property (nonatomic, strong) UILabel *LufDjKnameLabelRjatWG;

@property (nonatomic, strong) UILabel *wvuzPolimitLabellnCQvV;

@property (nonatomic, strong) UILabel *giAZzBstatusLabelmYmPuF;

@property (nonatomic, strong) UILabel *UmauIuborrowTimeTitleLabelacNcDq;

@property (nonatomic, strong) UILabel *tIYmThborrowTimeLabelpAoDrV;

@property (nonatomic, strong) UILabel *OEhpOHmoneyTitleLabelUtbXJD;

@property (nonatomic, strong) UILabel *TvtacpmoneyLabelIfJqAd;

@property (nonatomic, strong) UILabel *llMtYainterestTitleLabelidUKEP;

@property (nonatomic, strong) UILabel *hXmEPAintezCFozurestLabelGrseuqnMguKw;

@property (nonatomic, strong) UILabel *rqqcNGdateTitleLabeloaGttu;

@property (nonatomic, strong) UILabel *GGRvCldateLabelMvElwh;

@property (nonatomic, strong) UILabel *LFUwgeprotocolLabelRuOeSa;

@property (nonatomic, strong) UIImageView *qTVbTrarrowImgwIPROn;

@property (nonatomic, strong) UIButton *LYnZnJhandleBtnSWiHiO;

@end

@implementation MHHJvsJLCFMineInvestRecordCellJrPSbZ

- (void)reloadData
{
    self.backgroundColor = QTZ_White;
    if (self.invest) {
        
        if (!self.LufDjKnameLabelRjatWG) {
            self.LufDjKnameLabelRjatWG = [UILabel new];
            self.LufDjKnameLabelRjatWG.textColor = QTZ_Gray51;
            self.LufDjKnameLabelRjatWG.font = FONT(15);
            [self addSubview:self.LufDjKnameLabelRjatWG];
        }
        
        if (self.LufDjKnameLabelRjatWG) {
            self.LufDjKnameLabelRjatWG.text = self.invest.borrowName;
            [self.LufDjKnameLabelRjatWG sizeToFit];
            self.LufDjKnameLabelRjatWG.left = 12;
            self.LufDjKnameLabelRjatWG.top = 18;
        }
        
        if (!self.wvuzPolimitLabellnCQvV) {
            self.wvuzPolimitLabellnCQvV = [UILabel new];
            self.wvuzPolimitLabellnCQvV.textColor = Theme_Color;
            self.wvuzPolimitLabellnCQvV.font = FONT(12);
            [self addSubview:self.wvuzPolimitLabellnCQvV];
        }
        
        if (self.wvuzPolimitLabellnCQvV) {
            self.wvuzPolimitLabellnCQvV.text = [NSString stringWithFormat:@"期限%@天", self.invest.limitDay];
            [self.wvuzPolimitLabellnCQvV sizeToFit];
            self.wvuzPolimitLabellnCQvV.left = self.LufDjKnameLabelRjatWG.right + 10;
            self.wvuzPolimitLabellnCQvV.bottom = self.LufDjKnameLabelRjatWG.bottom;
        }
        
        if (!self.giAZzBstatusLabelmYmPuF) {
            self.giAZzBstatusLabelmYmPuF = [UILabel labelWithText:@"出借成功" textColor:RGB(32, 224, 45) font:FONT(12)];
            self.giAZzBstatusLabelmYmPuF.right = FULL_WIDTH - 12;
            self.giAZzBstatusLabelmYmPuF.bottom = self.LufDjKnameLabelRjatWG.bottom;
            [self addSubview:self.giAZzBstatusLabelmYmPuF];
        }
        
        if (!self.UmauIuborrowTimeTitleLabelacNcDq) {
            self.UmauIuborrowTimeTitleLabelacNcDq = [UILabel labelWithText:@"出借时间" textColor:QTZ_Gray51 font:FONT(12)];
            self.UmauIuborrowTimeTitleLabelacNcDq.left = self.LufDjKnameLabelRjatWG.left;
            self.UmauIuborrowTimeTitleLabelacNcDq.top = self.LufDjKnameLabelRjatWG.bottom + 20;
            [self addSubview:self.UmauIuborrowTimeTitleLabelacNcDq];
            [self.UmauIuborrowTimeTitleLabelacNcDq.layer addSublayer:[self addLineOriginPoint:CGPointMake(0, self.UmauIuborrowTimeTitleLabelacNcDq.height + 5) toPoint:CGPointMake(self.giAZzBstatusLabelmYmPuF.right, self.UmauIuborrowTimeTitleLabelacNcDq.height + 5) color:QTZ_Gray237 borderWidth:1]];
        }
        
        if (!self.tIYmThborrowTimeLabelpAoDrV) {
            self.tIYmThborrowTimeLabelpAoDrV = [UILabel new];
            self.tIYmThborrowTimeLabelpAoDrV.textColor = QTZ_Gray51;
            self.tIYmThborrowTimeLabelpAoDrV.font = FONT(12);
            [self addSubview:self.tIYmThborrowTimeLabelpAoDrV];
        }
        
        if (self.tIYmThborrowTimeLabelpAoDrV) {
            self.tIYmThborrowTimeLabelpAoDrV.text = [NSString stringWithDate:self.invest.addtime];
            [self.tIYmThborrowTimeLabelpAoDrV sizeToFit];
            self.tIYmThborrowTimeLabelpAoDrV.right = self.giAZzBstatusLabelmYmPuF.right;
            self.tIYmThborrowTimeLabelpAoDrV.centerY = self.UmauIuborrowTimeTitleLabelacNcDq.centerY;
        }
        
        if (!self.OEhpOHmoneyTitleLabelUtbXJD) {
            self.OEhpOHmoneyTitleLabelUtbXJD = [UILabel labelWithText:@"汇款本金" textColor:QTZ_Gray51 font:FONT(12)];
            self.OEhpOHmoneyTitleLabelUtbXJD.left = self.LufDjKnameLabelRjatWG.left;
            self.OEhpOHmoneyTitleLabelUtbXJD.top = self.UmauIuborrowTimeTitleLabelacNcDq.bottom + 15;
            [self addSubview:self.OEhpOHmoneyTitleLabelUtbXJD];
            [self.OEhpOHmoneyTitleLabelUtbXJD.layer addSublayer:[self addLineOriginPoint:CGPointMake(0, self.OEhpOHmoneyTitleLabelUtbXJD.height + 5) toPoint:CGPointMake(self.giAZzBstatusLabelmYmPuF.right, self.OEhpOHmoneyTitleLabelUtbXJD.height + 5) color:QTZ_Gray237 borderWidth:1]];
        }
        
        if (!self.TvtacpmoneyLabelIfJqAd) {
            self.TvtacpmoneyLabelIfJqAd = [UILabel new];
            self.TvtacpmoneyLabelIfJqAd.textColor = QTZ_Gray51;
            self.TvtacpmoneyLabelIfJqAd.font = FONT(12);
            [self addSubview:self.TvtacpmoneyLabelIfJqAd];
        }
        
        if (self.TvtacpmoneyLabelIfJqAd) {
            self.TvtacpmoneyLabelIfJqAd.text = self.invest.money;
            [self.TvtacpmoneyLabelIfJqAd sizeToFit];
            self.TvtacpmoneyLabelIfJqAd.right = self.giAZzBstatusLabelmYmPuF.right;
            self.TvtacpmoneyLabelIfJqAd.centerY = self.OEhpOHmoneyTitleLabelUtbXJD.centerY;
        }
        
        if (!self.llMtYainterestTitleLabelidUKEP) {
            self.llMtYainterestTitleLabelidUKEP = [UILabel labelWithText:@"回款收益" textColor:QTZ_Gray51 font:FONT(12)];
            self.llMtYainterestTitleLabelidUKEP.left = self.LufDjKnameLabelRjatWG.left;
            self.llMtYainterestTitleLabelidUKEP.top = self.OEhpOHmoneyTitleLabelUtbXJD.bottom + 15;
            [self addSubview:self.llMtYainterestTitleLabelidUKEP];
            [self.llMtYainterestTitleLabelidUKEP.layer addSublayer:[self addLineOriginPoint:CGPointMake(0, self.llMtYainterestTitleLabelidUKEP.height + 5) toPoint:CGPointMake(self.giAZzBstatusLabelmYmPuF.right, self.llMtYainterestTitleLabelidUKEP.height + 5) color:QTZ_Gray237 borderWidth:1]];
        }
        
        if (!self.hXmEPAintezCFozurestLabelGrseuqnMguKw) {
            self.hXmEPAintezCFozurestLabelGrseuqnMguKw = [UILabel new];
            self.hXmEPAintezCFozurestLabelGrseuqnMguKw.textColor = QTZ_Gray51;
            self.hXmEPAintezCFozurestLabelGrseuqnMguKw.font = FONT(12);
            [self addSubview:self.hXmEPAintezCFozurestLabelGrseuqnMguKw];
        }
        
        if (self.hXmEPAintezCFozurestLabelGrseuqnMguKw) {
            self.hXmEPAintezCFozurestLabelGrseuqnMguKw.text = self.invest.interest;
            [self.hXmEPAintezCFozurestLabelGrseuqnMguKw sizeToFit];
            self.hXmEPAintezCFozurestLabelGrseuqnMguKw.right = self.giAZzBstatusLabelmYmPuF.right;
            self.hXmEPAintezCFozurestLabelGrseuqnMguKw.centerY = self.llMtYainterestTitleLabelidUKEP.centerY;
        }
        
        if (!self.rqqcNGdateTitleLabeloaGttu) {
            self.rqqcNGdateTitleLabeloaGttu = [UILabel labelWithText:@"到期时间" textColor:QTZ_Gray51 font:FONT(12)];
            self.rqqcNGdateTitleLabeloaGttu.left = self.LufDjKnameLabelRjatWG.left;
            self.rqqcNGdateTitleLabeloaGttu.top = self.llMtYainterestTitleLabelidUKEP.bottom + 15;
            [self addSubview:self.rqqcNGdateTitleLabeloaGttu];
            [self.rqqcNGdateTitleLabeloaGttu.layer addSublayer:[self addLineOriginPoint:CGPointMake(0, self.rqqcNGdateTitleLabeloaGttu.height + 5) toPoint:CGPointMake(self.giAZzBstatusLabelmYmPuF.right, self.rqqcNGdateTitleLabeloaGttu.height + 5) color:QTZ_Gray237 borderWidth:1]];
        }
        
        if (!self.GGRvCldateLabelMvElwh) {
            self.GGRvCldateLabelMvElwh = [UILabel new];
            self.GGRvCldateLabelMvElwh.textColor = QTZ_Gray51;
            self.GGRvCldateLabelMvElwh.font = FONT(12);
            [self addSubview:self.GGRvCldateLabelMvElwh];
        }
        
        if (self.GGRvCldateLabelMvElwh) {
            self.GGRvCldateLabelMvElwh.text = self.invest.dqr;
            [self.GGRvCldateLabelMvElwh sizeToFit];
            self.GGRvCldateLabelMvElwh.right = self.giAZzBstatusLabelmYmPuF.right;
            self.GGRvCldateLabelMvElwh.centerY = self.rqqcNGdateTitleLabeloaGttu.centerY;
        }
        
        
        if (!self.LFUwgeprotocolLabelRuOeSa) {
            self.LFUwgeprotocolLabelRuOeSa = [UILabel labelWithText:@"查看出借协议" textColor:QTZ_Gray51 font:FONT(12)];
            self.LFUwgeprotocolLabelRuOeSa.left = self.LufDjKnameLabelRjatWG.left;
            self.LFUwgeprotocolLabelRuOeSa.top = self.rqqcNGdateTitleLabeloaGttu.bottom + 15;
            [self addSubview:self.LFUwgeprotocolLabelRuOeSa];
        }
        
        if (!self.qTVbTrarrowImgwIPROn) {
            self.qTVbTrarrowImgwIPROn = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon_list_detail_arrow"]];
            self.qTVbTrarrowImgwIPROn.centerY = self.LFUwgeprotocolLabelRuOeSa.centerY;
            self.qTVbTrarrowImgwIPROn.right = self.GGRvCldateLabelMvElwh.right;
            [self addSubview:self.qTVbTrarrowImgwIPROn];
        }
        
        if (!self.LYnZnJhandleBtnSWiHiO) {
            self.LYnZnJhandleBtnSWiHiO = [[UIButton alloc] initWithFrame:CGRectMake(self.LFUwgeprotocolLabelRuOeSa.left, 0, self.qTVbTrarrowImgwIPROn.right - self.LFUwgeprotocolLabelRuOeSa.left, 30)];
            self.LYnZnJhandleBtnSWiHiO.centerY = self.LFUwgeprotocolLabelRuOeSa.centerY;
            [self.LYnZnJhandleBtnSWiHiO bk_whenTapped:^{
                DarTMvJLCFMineInverstWebViewControllerJPeJHr *vc = [DarTMvJLCFMineInverstWebViewControllerJPeJHr new];
                vc.url = QTZ_WEB_URL(@"loan_agreement2.html");
                vc.id = self.invest.id;
                [[[JinLiCaiFuApplicationEntrace shareEntrance] currentNavController] pushViewController:vc animated:YES];
            }];
            [self addSubview:self.LYnZnJhandleBtnSWiHiO];
        }
        
    }
    
}

- (CAShapeLayer *)addLineOriginPoint:(CGPoint)p0 toPoint:(CGPoint)p1 color:(UIColor *)color borderWidth:(CGFloat)borderWidth {
    
    /// 线的路径
    UIBezierPath * bezierPath = [UIBezierPath bezierPath];
    [bezierPath moveToPoint:p0];
    [bezierPath addLineToPoint:p1];
    
    CAShapeLayer * ZLmcEJshapeLayerWDClkp = [CAShapeLayer layer];
    ZLmcEJshapeLayerWDClkp.strokeColor = color.CGColor;
    ZLmcEJshapeLayerWDClkp.fillColor  = [UIColor clearColor].CGColor;
    /// 添加路径
    ZLmcEJshapeLayerWDClkp.path = bezierPath.CGPath;
    /// 线宽度
    ZLmcEJshapeLayerWDClkp.lineWidth = borderWidth;
    return ZLmcEJshapeLayerWDClkp;
}

@end
